package com.example.meterialproject.fragments

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.meterialproject.R
import com.example.meterialproject.adapter.TextAdapter

/**
 *
 * @ClassName: CoordinatorFragment
 * @Author: android 超级兵
 * @CreateDate: 4/15/22$ 2:56 PM$
 * TODO
 */
class CoordinatorFragment : Fragment() {

    companion object {
        const val KET = "key"
    }

    private val key by lazy {
        requireArguments().getString(KET) ?: ""
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return inflater.inflate(R.layout.fragment_coordinator, container)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        Log.i("szjFragment", key)
        view.findViewById<RecyclerView>(R.id.recycler_view).apply {
            layoutManager = LinearLayoutManager(requireContext())
            adapter =
                TextAdapter(requireContext(), (0..1_000).map { "${key}-数据:${it}" }.toList())
        }
    }
}